<?php
namespace Models\Model;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;
use Zend\Db\Sql\Predicate;
use Zend\Db\Sql\Expression;
class DictionaryTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }
	public function getdictionarylist()
    {
		$select = $this->tableGateway->getSql()->select();
		$rand = new \Zend\Db\Sql\Expression('RAND()');
		$select->order($rand);
        $select->limit(4);  
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;
	}
	
	public function getdictionaryData($word)
    {	
		$select = $this->tableGateway->getSql()->select();
		$select->where('word="'.$word.'"')->limit(1);	
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;
	}
	
	public function getDictionaryword()
    {
		$select = $this->tableGateway->getSql()->select();
		$rand = new \Zend\Db\Sql\Expression('RAND()');
		$select->order($rand);
        $select->limit(1); 
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;
	}
	
}